package com.qf.conmmon;

import com.sun.org.apache.xpath.internal.operations.Bool;

import java.util.HashMap;

/**
 * @propram: IntelliJ IDEA
 * @description:
 * @author: 秦先发
 * @create: 2021-09-24 17:32
 **/
public class R  extends HashMap<String,Object> {
    public static R ok(){
        R r = new R();
        r.put("code", 0);
        r.put("msg","成功");
        return r;
    }
    public static R error(){
        R r = new R();
        r.put("code", 500);
        r.put("msg","失败");
        return r;
    }
    public static R getR(Object flag){
        if (flag instanceof Boolean) {
            if((boolean)flag){
                return R.ok();
            }
        }
        if (flag instanceof  Integer) {
            if ((Integer)flag>0) {
                return R.ok();
            }
        }
        if(flag!=null){
            R ok = R.ok();
            ok.put("page", flag);
            return ok;
        }
        return R.error();
    }
    public static R  saveR(String msg,Object obj){
        if(obj!=null){
            R ok = R.ok();
            ok.put(msg, obj);
            return ok;
        }
        return R.error();
    }

}
